package net.qhzw.vip.qiyu.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.qhzw.vip.qiyu.model.LoginForm;
import net.qhzw.vip.qiyu.model.LoginUser;
import net.qhzw.vip.qiyu.result.JsonResult;
import net.qhzw.vip.qiyu.service.SysLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 登录的控制器
 */
@RestController
@Api(tags = "登录的控制器")
@RequestMapping("oauth")
public class SysLoginController {

    @Autowired
    private SysLoginService loginService;

    @PostMapping("/user/login")
    @ApiOperation(value = "后台管理人员登录")
    public JsonResult<LoginUser> userLogin(@RequestBody @Validated LoginForm param) {
        param.setLoginType("admin_type");
        LoginUser loginUser = loginService.login(param);
        return JsonResult.ok(loginUser);
    }

    @PostMapping("/member/login")
    @ApiOperation(value = "后台管理人员登录")
    public JsonResult<LoginUser> memberLogin(@RequestBody @Validated LoginForm param) {
        param.setLoginType("member_type");
        LoginUser loginUser = loginService.login(param);
        return JsonResult.ok(loginUser);
    }


}
